package com.sshiro.controller.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.sshiro.Global;

@Controller
@RequestMapping(Global.ADMIN_PATH + "/account")
public class AccountController extends BaseAdminController {

	@RequestMapping(value = "/login")
	public String login(HttpServletRequest request, HttpServletResponse response) {
		logger.info("访问登录页面");

		// @CookieValue("name") String name,
		// logger.info("CookieValue.name" + name);
		return "admin/login";
	}

	@RequestMapping(value = "/sns/login/auth")
	public String login4sns(HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("社会化登录");
		return "admin/login";
	}

	@RequestMapping(value = "/logout")
	public String logout(HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("用户登出");
		return "admin/login";
	}
	
	@RequestMapping(value = "/check", method = RequestMethod.POST)
	public String check(@RequestParam(value = "user") String username,
			@RequestParam(value = "pwd") String password,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		logger.info("用户身份校验");
		logger.info("username:" + username);
		logger.info("password:" + password);

		logger.info("callback:" + request.getParameter("callback"));
		logger.info("sid:" + request.getParameter("sid"));

		return "redirect:/admin/index";
	}

}
